import $http from '../request';

const URL_PREFIX = '/datasource/connection';

export const $DataSourceApi = {

	/**
	 * 创建连接
	 * @param param
	 * @returns {Promise<*>}
	 */
	createConnection: (param) => {
		return $http.$post(URL_PREFIX + '/create', param, {});
	},

	updateConnection: (param) => {
		return $http.$post(URL_PREFIX + '/update', param, {})
	},

	/**
	 * 测试数据库连接
	 * @param param
	 * @returns {Promise<*>}
	 */
	testConnect: (param) => {
		return $http.$post(URL_PREFIX + "/testConnect", param, {})
	},

	/**
	 * 查询
	 * @param param
	 * @returns {Promise<*>}
	 */
	list: () => {
		return $http.$get(URL_PREFIX + '/list', null)
	},

	/**
	 * 批量删除
	 * @param param
	 * @returns {Promise<*>}
	 */
	batchDelete: (param) => {
		return $http.$post(URL_PREFIX + '/batchRemove', param, {})
	},


}


